<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html><head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>GTest Admin Console</title>
<link href="http://code.google.com/css/codesite.pack.01312008.css" type="text/css" rel="stylesheet">
<link href="http://code.google.com/css/semantic_headers.css" rel="stylesheet" type="text/css">
</head>

<body class="gc-documentation">
<div id="gc-container">

<div id="gc-header">
<h1>GTest Admin Console</h1>
</div> <!-- end gc-header -->

<div id="codesiteContent">
<div id="gc-topnav">
  <h1>GTest Admin Console</h1>
  <ul id="docs" class="gc-topnav-tabs">
    <li id="home_link"><a href="/admin/">Home</a></li>
  </ul>
</div> <!-- end gc-topnav -->

    <div class="g-section g-tpl-170">
      <div class="g-unit g-first" id="gc-toc">
        <ul class="treelist tlw-nested-only tlw-processed tlw-instance-0">
  <li><a href="/admin/">Home</a></li>
</ul>
<div class="line"></div>
<ul class="treelist tlw-nested-only tlw-processed tlw-instance-1">
{% block sidebar %}
      <li><a href="#">Import/Export</a></li>
      <li><a href="/admin/">View Data</a></li>
      <!--
      <li style="padding-top: 0pt; padding-bottom: 0pt;">
        <div class="tlw-title tlw-branch"><a href="http://code.google.com/appengine/docs/gettingstarted/">Getting Started</a></div><ul style="display: block;" id="1-sub-0">
        <li><a href="http://code.google.com/appengine/docs/gettingstarted/introduction.html">Introduction</a></li>
        <li><a href="http://code.google.com/appengine/docs/gettingstarted/devenvironment.html">The Development Environment</a></li>
        <li><a href="http://code.google.com/appengine/docs/gettingstarted/staticfiles.html">Using Static Files</a></li>
        <li><a href="http://code.google.com/appengine/docs/gettingstarted/uploading.html">Uploading Your Application</a></li>
        </ul>
      </li>
      <li><a href="http://code.google.com/appengine/docs/quotas.html">Quotas</a></li>
      -->
{% endblock %}
</ul>
<div class="line"></div>

      </div>
      
      <div style="position: relative;" class="g-unit" id="gc-pagecontent">
        <div id="notice">{{ notice }}</div>
        <h1 class="page_title">{% block title %}Creating, Getting and Deleting Data{% endblock %}</h1>
{% block content %}
<p>The datastore API represents entities as instances of model classes.
Methods of a model instance create, update and delete the entity.
Entities can be fetched from the datastore as model instances using
queries or keys.</p> 

<ul>
  <li><a href="#Creating_and_Updating_an_Entity">Creating and Updating an Entity</a></li>
  <li><a href="#Getting_Entities_Using_a_Query">Getting Entities Using a Query</a></li>
  <li><a href="#Getting_an_Entity_Using_a_Key">Getting an Entity Using a Key</a></li>
  <li><a href="#Deleting_an_Entity">Deleting an Entity</a></li>
</ul>


<h2 id="Creating_and_Updating_an_Entity">Creating and Updating an Entity</h2>

<p>Instances of <a href="http://code.google.com/appengine/docs/datastore/modelclass.html">Model</a> (and <a href="http://code.google.com/appengine/docs/datastore/expandoclass.html">Expando</a>)
classes represent datastore entities. An application creates a new
entity of a given kind by calling the constructor of the model class
that corresponds with the kind.</p>
<p>The new entity is not created in the datastore until the instance is "put" for the first time, either by calling the <a href="http://code.google.com/appengine/docs/datastore/modelclass.html#Model_put">put()</a> method on the instance, or by passing the instance to the <a href="http://code.google.com/appengine/docs/datastore/functions.html#put">db.put()</a> function.</p>
<p>If an instance has been stored before, the put() method updates the existing entity.</p>

<p>Queries return results as model instances.  These instances can be modified and put back into the datastore.</p>
<h2 id="Deleting_an_Entity">Deleting an Entity</h2>

<p>An application can delete an entity from the datastore using a model instance or a Key.  The model instance's <a href="http://code.google.com/appengine/docs/datastore/modelclass.html#Model_delete">delete()</a> method deletes the corresponding entity from the datastore.  The <a href="http://code.google.com/appengine/docs/datastore/functions.html#delete">delete()</a> function takes a Key or list of Keys and deletes the entity (or entities) from the datastore.</p>
<p>Deleting an entity does not change any Key values in the datastore
that may have referred to the entity. If your application may attempt
to de-reference a Key value for a deleted entity, the application
should do so using <a href="http://code.google.com/appengine/docs/datastore/functions.html#get">db.get()</a>, then test the return value before accessing properties.</p>

<p>Deleting an entity that is an ancestor for other entities does not
affect the other entities. As long as the application does not depend
on the existence of the ancestor to build keys for the descendant
entities, the application can still access the descendants.</p>



   
      <div class="" style="height: 3597px;" id="gc-collapsible"></div>
      {% endblock %}
      </div><!-- end gc-pagecontent -->
   </div><!-- end gooey wrapper -->

    </div> <!-- end codesite content -->

<div id="gc-footer" dir="ltr">

</div><!-- end gc-footer -->

</div><!-- end gc-containter -->

</body></html>